package game;

import java.awt.Graphics2D;
import java.awt.Point;

public class Bar extends GameObject
{
	private static final long serialVersionUID = 1L;
	int fixedBar, firstHP ; //tamanho da barra - tempo total de cada turno
	float hpBar; //tempo atual do turno
	int indexRedImage = 7; // index da imagem
	int proporcaoHP; //proporcao do tempo em relacao ao tamanho da barra
	
	public Bar(int indexImage, Point pos, Point sizeObject, float HP)
	{
		super(pos, sizeObject);
		indexRedImage = indexImage;
		setImage(indexImage);
		this.hpBar = HP;
		this.firstHP = (int)HP;
		
		// TODO Auto-generated constructor stub
	}

	public void UpdateBar(float hp, Point position, int xObject)
	{
		this.hpBar = hp;
		this.position = position;
		fixedBar = xObject;
		proporcaoHP = (int)((hp * fixedBar)/firstHP);
	}
	
	@Override
	public void draw(Graphics2D g) 
	{
		// TODO Auto-generated method stub
		
		g.drawImage(LoadImages.getImage(indexRedImage), (int)position.getX(), (int)(position.getY() - 15), proporcaoHP, 5, null, this);
		g.drawImage(getImage(), (int)position.getX(), (int)(position.getY() - 15), fixedBar, 5, null, this);
		
	}
	
	
	

}
